import React from "react"
import LoginStore from "./login.Store"
import UserStore from "./user.Store"
import ChannelStore from "./channel.Store"

class RootStore {
  constructor() {
    this.loginStore = new LoginStore()
    this.UserStore = new UserStore()
    this.channelStore = new ChannelStore()
  }
}
const rootStore = new RootStore()
//创建context对象
const context = React.createContext(rootStore)

const useStore = () => React.useContext(context)
// 2.在顶层组件通过‘provider’提供数据
// 3.在底层组件通过‘useContext（context）’函数获取数据
export { useStore }